package com.chuangke.elasticsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;

@Configuration
public class ElasticConfig {

	@Value("${es.host}")
	public String host;
	@Value("${es.port}")
	public int port;
	@Value("${es.scheme}")
	public String scheme;

//	@Bean
//	public RestClient elasticsearchRestClient() {
//		return RestClient.builder(new HttpHost(host, port, scheme)).build();
//	}
//
//	@Bean
//	public ElasticsearchClient restHighLevelClient(@Autowired RestClient restClient) {
//		ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
//        return new ElasticsearchClient(transport);
//	}
}
